package com.yxc.translationdemo.const_enum;

import com.yxc.translationdemo.transcode.TranslationData;

import java.lang.reflect.Field;

/**
 * @author: YXC
 * @time: 2023/4/23 15:19
 **/
public enum CountryEnum implements TranslationData<Integer> {

    /**
     * 中国
     */
    CHINA("中国", 1),
    /**
     * 美国
     */
    USA("美国", 2);

    private String name;

    private Integer code;

    CountryEnum(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String get(Integer key, Field field) {
        if (key != null) {
            for (CountryEnum value : CountryEnum.values()) {
                if (value.getCode().equals(key)) {
                    return value.getName();
                }
            }
        }
        return "";
    }
}
